home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Modules / BackSpaceModules / Source / Lizard / LizardViewPart.m < prev    next >
Text File  |  1994-05-04  |  2KB  |  96 lines

  1. #import "LizardViewPart.h"
  2. #import "Thinker.h"
  3. #import <appkit/NXImage.h>
  4. #import <appkit/Panel.h>                // for NXRunAlertPanel()
  5. #import <dpsclient/wraps.h>
  6. #import <libc.h>
  7. #import <math.h>
  8.  
  9. @implementation LizardView
  10.  
  11. - oneStep
  12. {
  13.   p=n; n=(n+1)%(NUMLINES-1);
  14.   erase=(n-(NUMLINES*.9)); if(erase<0) erase+=(NUMLINES-1);
  15.   if(n>(NUMLINES-1))n=0;
  16.   
  17.   t1[n]=t1[p]+0.008; if(t1[n]>(2*PI)) t1[n]-=(2*PI);
  18.   t2[n]=t2[p]+0.01; if(t2[n]>(2*PI)) t2[n]-=(2*PI);
  19.   
  20.   t3[n]=t3[p]+0.02; if(t3[n]>(2*PI)) t3[n]-=(2*PI);
  21.   t4[n]=t4[p]+0.009; if(t4[n]>(2*PI)) t4[n]-=(2*PI);
  22.   
  23.   t5[n]=t5[p]+0.01; if(t5[n]>(2*PI)) t5[n]-=(2*PI);
  24.   t6[n]=t6[p]+0.01; if(t6[n]>(2*PI)) t6[n]-=(2*PI);
  25.   
  26.   t-=0.3; if(t<0)t+=(2*PI);
  27.   
  28.   x1[n]=(cos(t1[n])*(s1))+midx;
  29.   yc1[n]=(sin(t2[n])*(s2))+midy;
  30.   x2[n]=(cos(t3[n])*(s1))+midx;
  31.   y2[n]=(sin(t4[n])*(s2))+midy;
  32.   x3[n]=(cos(t5[n])*(s1))+midx;
  33.   y3[n]=(sin(t6[n])*(s2))+midy;
  34.  
  35.   PSsetrgbcolor(0.0,0.0,0.0);
  36.   PSmoveto(x1[erase], yc1[erase]); PSlineto(x2[erase], y2[erase]);
  37.   PSmoveto(x2[erase], y2[erase]);  PSlineto(x3[erase], y3[erase]);
  38.   PSmoveto(x3[erase], y3[erase]);  PSlineto(x1[erase], yc1[erase]);
  39.   PSstroke();
  40.  
  41.  
  42.   if ([self shouldDrawColor])
  43.   PSsetrgbcolor((cos(t1[n])+1.0)/2.0,
  44.                 (cos(t3[n])+1.0)/2.0,
  45.                 (cos(t5[n])+1.0)/2.0);
  46.   else PSsetrgbcolor(1.0, 1.0, 1.0);
  47.   PSmoveto(x1[n], yc1[n]); PSlineto(x2[n], y2[n]);
  48.   PSmoveto(x2[n], y2[n]);  PSlineto(x3[n], y3[n]);
  49.   PSmoveto(x3[n], y3[n]);  PSlineto(x1[n], yc1[n]);
  50.   PSstroke();
  51.  
  52.   return self;
  53. }
  54.  
  55. - initFrame:(NXRect *)frameRect
  56. {
  57.     [super initFrame:frameRect];
  58.     [self newSize];
  59.     return self;
  60. }
  61.  
  62. - sizeTo:(NXCoord)width :(NXCoord)height
  63. {
  64.     [super sizeTo:width :height];
  65.     [self newSize];
  66.     return self;
  67. }
  68.  
  69. - newSize
  70. {
  71.   urx=bounds.size.width;
  72.   ury=bounds.size.height;
  73.   
  74.   midx=urx/2;
  75.   midy=ury/2;
  76.  
  77.   n = 0;
  78.   t = 0;
  79.   
  80.   // phases of the three points;
  81.   p1=0;
  82.   p2=(4*PI)/3;
  83.   p3=(2*PI)/3;
  84.   
  85.   // starting angle of each point;
  86.   t1[0]=0;
  87.   t2[0]=p2;
  88.   t3[0]=p3;
  89.   
  90.   s1 = midx; s2 = midy;
  91.  
  92.   return self;
  93. }
  94.  
  95. @end
  96.